home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MISC / SHELL.ARC / Shell / Sources / c / BlockRect2 < prev    next >
Encoding:
Text File  |  1994-06-25  |  1.9 KB  |  110 lines

  1. #include "DeskLib:WimpSWIs.h"
  2. #include "DeskLib:GFX.h"
  3.  
  4. #include "Shell.BlockRct.h"
  5. #include "Shell.Extra.h"
  6. #include "Shell.SafeAlloc.h"
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13. typedef struct    {
  14.     Shell_GeneralBlockRectFn2    fn;
  15.     void                *reference;
  16.     int                width, height;
  17.     int                maxx, maxy;
  18.     }
  19.     Shell_GeneralBlockRectInfo2;
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. static void Shell_GeneralBlockRectRedrawer2(
  29.     Shell_convertpoint    convert,
  30.     wimp_point        rectsize,
  31.     void            *reference,
  32.     const wimp_rect        *redrawrect
  33.     )
  34. {
  35.     wimp_rect            rect    = *redrawrect;
  36.     Shell_GeneralBlockRectInfo2    *info    = (Shell_GeneralBlockRectInfo2 *) reference;
  37.  
  38. Shell_ConvertToSubRect2( &rect, rectsize);
  39. rect.min.x /= info->width;
  40. rect.max.x /= info->width;
  41. rect.min.y /= info->height;
  42. rect.max.y /= info->height;
  43.  
  44.     {    int i, j;
  45.  
  46.     for ( i=rect.min.x; i<=rect.max.x; i++)    {
  47.         int x = i*info->width;
  48.         for ( j=rect.min.y; j<=rect.max.y; j++)    {
  49.             info->fn( i, j, info->maxx, info->maxy, info->reference);
  50.             Shell_RectangleFill3(
  51.                 x, j*info->height,
  52.                 info->width    - Shell_PIXELXSIZE,
  53.                 info->height    - Shell_PIXELYSIZE,
  54.                 convert
  55.                 );
  56.             }
  57.         }
  58.     }
  59.  
  60. return;
  61. }
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. Shell_rectblock *Shell_AddGeneralBlockRect2(
  71.     Shell_windblock            *wind,
  72.     int                x,
  73.     int                y,
  74.     int                maxx,
  75.     int                maxy,
  76.     int                width,
  77.     int                height,
  78.     Shell_GeneralBlockRectFn2    fn,
  79.     const void            *reference
  80.     )
  81. {
  82.     wimp_rect            rect;
  83.     Shell_GeneralBlockRectInfo2    *info;
  84.     Shell_rectblock            *r;
  85.  
  86. info = Shell_SafeMalloc( sizeof( Shell_GeneralBlockRectInfo2));
  87.  
  88. info->fn    = fn;
  89. info->width    = width;
  90. info->height    = height;
  91. info->maxx    = maxx;
  92. info->maxy    = maxy;
  93. info->reference    = (void *) reference;
  94.  
  95. rect.max.x    = x+maxx*width;
  96. rect.max.y    = y+maxy*height;
  97. rect.min.x    = x;
  98. rect.min.y    = y;
  99.  
  100. r = Shell_AddRectangle( wind, &rect, Shell_GeneralBlockRectRedrawer2, (void *) info);
  101.  
  102. /* Could call Shell_MakeRectIcon here to give the blockrect a border.    */
  103. /* However, I sometimes want to graba blockrect to put into a paper and    */
  104. /* it looks better without the border on paper.                */
  105.  
  106. return r;
  107. }
  108.  
  109.  
  110.